﻿/**
 * @author sminutoli
 * version 1.0
 * revisar el tema del intervalo para ver cuantos eventos dispachea
 */
 
import com.dinmax.flash.draw.cabeza.*

class ButtonBarCabeza
extends ControlCabeza 
implements SelectedListener{

	private var buttons:Array;
	private var linkageID:String;
	//private var activeButton:ButtonCabeza;	
		
	function ButtonBarCabeza(){
		super();
		this.buttons = new Array();
		return;
	}
	
	public function onLoad():Void{
		var parent:ControlCabeza = ControlCabeza(this._parent);
		if(parent) parent.initChild(this);
	};
	
	public function getLinkageID():String{
		return this.linkageID;
	}
	
	public function setLinkageID(linkageid:String):Void{
		this.linkageID = linkageID;
		return;
	}
	
	public function addButton(label:String, value:Object):Void {
		//trace("ButtonBarCabeza | addButton | instance= "+this+"label= "+label);
		var btn:ButtonCabeza = ButtonCabeza(this.attachMovie(linkageID, "mcButton"+this.buttons.length, this.getNextHighestDepth()));
		btn.addListener(this);
		btn.setLabel(label);
		btn.setValue(value);
		btn._visible = false;
		this.buttons.push(btn);
		this.layout();
		return;
	}
	
	public function getButtons():Array {
		return this.buttons;
	}
	
	private function layout():Void {
		//trace("ButtonBarCabeza.as | layout | no hace nada");
		return;
	}
	
	public function refresh():Void{
		//MISION: hacer mierda a todo los movieclips que tenga adentro
		return;
	}
	
	public function selected(control:ControlCabeza):Void{
		if(control != this.getValue()){
			ButtonCabeza(this.getValue()).setActive(false);
			ButtonCabeza(control).setActive(true);
			this.setValue(control);
			this.selectEvent();
		}
		/*this.control = control;
		this.ControlCabeza.setValue(Object);*/
		return;
	}
		
}